#ifndef SINETABLEGENERATOR_H
#define SINETABLEGENERATOR_H
////////////////////////////////////////////////////////////////////////////////////////
//	Name:		SineTableGenerator v1.0
//	Author:	Raul James (raul.james49@gmail.com)
//	Date:		May 28, 2010
//	Descr:	Dynamically generates sinebased values
////////////////////////////////////////////////////////////////////////////////////////

#define M_PI		3.14159265358979323846	/* pi */

///////////////////////////////////////////
//	Name:	  get Sine
//	Author:	Raul James (raul.james49@gmail.com)
//	Descr:	Calculates a sine value given a
//					angle in degs.
//			
//	Args:		intDeg - angle in degrees
///////////////////////////////////////////
double getSine(unsigned int intDeg){
//	return(sin(intDeg*M_PI/180));
 int sinvalue =SinE3(intDeg);
	return((double)sinvalue/1000);
}

///////////////////////////////////////////
//	Name:		Generate Sine Table
//	Author:	Raul James (raul.james49@gmail.com)
//	Descr:	Generates a sinetable using x
//					points to constitute a full
//					sinusoidal pattern. At least 12
//					points are necessary to
//					create a sinusoidal pattern.
//			
//	Args:		*ptrStart - pointer of the sinearray
//					size			-	size of the sinearray
//	Return:	0=error; 1=succes
///////////////////////////////////////////
int generateTable(unsigned short int *ptrStart, int size){
  int x; //y, z;
  unsigned short int *ptrCurrent;
	if((size%12)!=0){return(0);}				// control if the minimum value is set
	
	ptrCurrent = ptrStart;																							// set currentpointer to the value
	
	for(x=0; x < size; x++){																						// process the necessary sines for the given size

		*(ptrCurrent++) = (int) (getSine((x)*(360/size))*ZERO_MAXPOT+POTOFFSET);	// write x-sineval to mem and incr. ptr
		}

	return(1);
}
#endif